<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="common/include :: header('流程定义列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li class="select-time">
                            <label>部署时间：</label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="beginTime"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="endTime"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="deployMentlHandler()" shiro:hasPermission="business:serviceItem:add">
                <i class="fa fa-plus"></i> 流程文件部署
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="common/include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('business:definitionDetail:edit')}]];
    var removeFlag = [[${@permission.hasPermi('business:definitionDetail:remove')}]];
    var prefix = ctx + "/business/bpmnInfo";
    $(function() {
        var options = {
            url: prefix + "/query",
            modalName: "流程定义",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'deploymentId',
                    title: '部署ID',
                    visible: false
                },
                {
                    field: 'actProcessId',
                    title: '流程定义id'
                },
                {
                    field: 'bpmnName',
                    title: '流程名称'
                },
                {
                    field: 'info',
                    title: '描述信息',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value, 5);;
                    }
                },
                {
                    field: 'deployTime',
                    title: '部署时间'
                },
                {
                    field: 'resourceName',
                    title: '流程文件',
                    formatter:function(value, row, index) {
                        var url = prefix+"/readResource?deploymentId="+row.deploymentId+"&type=xml";
                        return '<a class="btn btn-info btn-xs " href="' + url + '" target="_blank"><i class="fa fa-search"></i></a> ';
                    }
                },
                {
                    field: 'diagramResourceName',
                    title: '流程图',
                    formatter:function(value, row, index) {
                        var url = prefix+"/readResource?deploymentId="+row.deploymentId+"&type=png";
                        return '<a class="btn btn-info btn-xs " href="' + url + '" target="_blank"><i class="fa fa-search"></i></a> ';
                    }
                },
                {
                    field: 'opertion',
                    title: '操作',
                    formatter:function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs "  href="javascript:void(0)" ' +
                            'onclick="deleteHandler(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');

                        return actions.join('');
                    }
                }

            ]
        };
        $.table.init(options);
    });
    function deleteHandler(id){
        $.modal.confirm("确认删除选中流程定义么?", function() {
            $.operate.submit(prefix + "/delete?id="+id, "get");
        });
    }
    function deployMentlHandler(){
        $.modal.open("流程部署", prefix + "/deployPage");
    }
</script>
</body>
</html>